#include "head_cli.h"
int main (int argc, char * argv [])
{	
	if (argc != 2) {
	printf("输入格式错误，eg: ./2_ip + vm 的网络ip\n");
	return 1;
	}

	char Cmd[50];
	//通讯对象信息
	//struct sockaddr_in client;//声明IPv4的专用结构体对象 
	struct sockaddr_in client;
	//bzero(&addr, sizeof(addr));
	memset(&client, 0, sizeof(client));
	client.sin_family = AF_INET;
	client.sin_addr.s_addr = inet_addr(argv[1]);
	client.sin_port = htons(12345);
	//调用目标

	
	while (1)
		{
			bzero(Cmd, 50);
			printf("ftp>");
			fgets(Cmd,sizeof(Cmd),stdin); //获取按键的值
				// 移除 fgets 读取的换行符
				size_t len = strlen(Cmd);
			if (len > 0 && Cmd[len - 1] == '\n') {
			Cmd[len - 1] = '\0';
			}
			if(strncmp(Cmd, "help",4) == 0){
				help_cmd();
			}else if(strncmp(Cmd, "quit",4) == 0){
				quit_cmd();
			}else if(strncmp(Cmd, "ls",2) == 0){    //客户端和服务端各自显示本地文件
				ls_cmd(client,Cmd);
			}else if(strncmp(Cmd, "put", 3) == 0){
				put_cmd(client,Cmd);
			}else if(strncmp(Cmd, "get", 3) == 0){  //
				get_cmd(client, Cmd);
			}else if(strncmp(Cmd, "LS",2) == 0){   //客户端显示服务端的ls
				lscli_cmd();
			}else{
				printf("无效输入\n");
			}

			
		}








	

	return 0;
}
